##############################################################
# CMakeLists.txt for a ROS package within the low-cost-vision
# build system. 
# 
# Created by Pascal Muller <pascalmuller@gmail.com>, 09-02-2012
# 
# 09-02-2012 Initial version
# 
#############################################################

cmake_minimum_required(VERSION 2.4.6)
# Include all rosbuild macros
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

# Only add the target to the generated makefile if all external library dependencies 
# are satisfied. 
if(OpenCV_FOUND AND MODBUS_FOUND AND wxWidgets_FOUND AND GLUT_FOUND AND OPENGL_FOUND AND OPENGL_GLU_FOUND AND Boost_FOUND) 
	# Initialize ROS package to be in our build system. 
	lcv_rospack_init("huniplacer_3d" true true)

	# Add executables as documented by ROS
	rosbuild_add_executable(huniplacer_3d src/Callbacks.cpp src/Indicator.cpp src/InfoPanel.cpp src/LogPanel.cpp src/CrateModel.cpp src/CrateContent.cpp src/IoHandlers.cpp src/main.cpp src/RangeModel.cpp src/Render.cpp src/RobotModel.cpp src/PanelPart.cpp src/ProgressBar.cpp src/Picking.cpp)

	# Add dependencies to our libraries and other ROS packages in the same directory as this one. 
	add_dependencies(huniplacer_3d deltarobot vision huniplacer Fiducial xml_io)

	# Include and link to libraries
	include_directories(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR} ${OpenCV_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
	target_link_libraries(huniplacer_3d ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
	target_link_libraries(huniplacer_3d ${OpenCV_LIBS} ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY})

	# Include our libraries, they are all exported in Libraries/LibrariesExport.cmake
	include_directories(${LIB_HUNIPLACER_INCLUDE} ${LIB_FIDUCIAL_INCLUDE} ${LIB_DATATYPES_INCLUDE} ${LIB_XMLIO_INCLUDE})

	include_directories("../vision/include/") #ROS packages should never ever ever depend on each other in this way. This hack is only here to make it build, but the code should be fixed!

	# Link target to our libraries
	target_link_libraries(huniplacer_3d huniplacer Fiducial xml_io)
	
	# MUST be called after lcv_rospack_init to clean up after ROSBUILD!
	lcv_rospack_end()

# Oh, let's just warn we omitted an target. 
else(OpenCV_FOUND AND MODBUS_FOUND AND wxWidgets_FOUND AND GLUT_FOUND AND OPENGL_FOUND AND OPENGL_GLU_FOUND AND Boost_FOUND) 
	lcv_cannot_build(huniplacer_3d, "ROS/huniplacer_3d")
endif(OpenCV_FOUND AND MODBUS_FOUND AND wxWidgets_FOUND AND GLUT_FOUND AND OPENGL_FOUND AND OPENGL_GLU_FOUND AND Boost_FOUND) 
